package main

import (
	"github.com/gin-gonic/gin"
	"hello/handlers"
	"hello/middleware"
)

func initRoutes(engine *gin.Engine) {
	apiV1 := engine.Group("/api/v1")
	{
		userGroup := apiV1.Group("/user")
		{
			userGroup.POST("/login", handlers.LoginUser)
			authenticatedGroup := userGroup.Use(middleware.JWTAuthMiddleware())
			{
				authenticatedGroup.POST("/create", handlers.CreateUser)
				authenticatedGroup.GET("/info", handlers.GetUser)
				authenticatedGroup.PUT("/update", handlers.UpdateUser)
				authenticatedGroup.GET("/list", handlers.ListUser)
				authenticatedGroup.DELETE("/delete", handlers.DeleteUser)
				authenticatedGroup.POST("/UploadFile", handlers.UploadFile)
			}
		}
		packageGroup := apiV1.Group("/package").Use(middleware.JWTAuthMiddleware())
		{
			packageGroup.POST("/create", handlers.CreatePackage)
			packageGroup.POST("/list", handlers.ListPackage)
		}
		storageGroup := apiV1.Group("/storage").Use(middleware.JWTAuthMiddleware())
		{
			storageGroup.POST("/create", handlers.CreateStorage)
		}
	}
}
